package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Operating {
    private int operatingId;
    private String operatingType;
    private Integer operatingState;
    private Collection<Operarrange> operarrangesByOperatingId;

    @Id
    @Column(name = "operating_id", nullable = false)
    public int getOperatingId() {
        return operatingId;
    }

    public void setOperatingId(int operatingId) {
        this.operatingId = operatingId;
    }

    @Basic
    @Column(name = "operating_type", nullable = true, length = 30)
    public String getOperatingType() {
        return operatingType;
    }

    public void setOperatingType(String operatingType) {
        this.operatingType = operatingType;
    }

    @Basic
    @Column(name = "operating_state", nullable = true)
    public Integer getOperatingState() {
        return operatingState;
    }

    public void setOperatingState(Integer operatingState) {
        this.operatingState = operatingState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Operating operating = (Operating) o;
        return operatingId == operating.operatingId &&
                Objects.equals(operatingType, operating.operatingType) &&
                Objects.equals(operatingState, operating.operatingState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(operatingId, operatingType, operatingState);
    }

    @OneToMany(mappedBy = "operatingByOperatingId")
    public Collection<Operarrange> getOperarrangesByOperatingId() {
        return operarrangesByOperatingId;
    }

    public void setOperarrangesByOperatingId(Collection<Operarrange> operarrangesByOperatingId) {
        this.operarrangesByOperatingId = operarrangesByOperatingId;
    }
}
